<?php
$oAddress = new Address();
if(empty($_POST['formAction'])){
	$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
	if($id > 0){
		$address_info = $oAddress->get_row($id);
		if(!empty($address_info)){
			$citys = $oAddress->get_citys($address_info['province_id']);
			$areas = $oAddress->get_areas($address_info['city_id']);
			$address_info['city_options'] = make_options($citys, '', $address_info['city_id']);
			$address_info['area_options'] = make_options($areas, '', $address_info['area_id']);
		}
	}else{
		$address_info = array(
			'id'			=> 0,
			'province_id'	=> 0,
			'besttime'		=> '',
		);
	}
	$provinces = $oAddress->get_provinces();
	$address_info['province_options'] = make_options($provinces, '', $address_info['province_id']);
	$address_info['besttime'] = make_options(Statics::$delivery_date_arr, '', $address_info['besttime']);
	$vars['address_info'] = $address_info;
}else{
	$r = $oAddress->edit($__userinfo['userid'], $_POST);
	ajax_msg($r['result'], $r['rmsg'], 'callback_address_save');
}
?>